package cc.vv.btpartyjob.partymanager.delegate

import android.annotation.SuppressLint
import android.support.v4.view.ViewPager
import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.adapter.ManagerViewPageAdapter
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 单位报到托管类
 * Created by Chen.qi on 2018/10/24.
 */
@SuppressLint("SetTextI18n")
class RegisterStaticsActivityDelegate : BaseAppDelegate() {


    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_register_statistics
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_ars_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_ars_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置已报到未报到的状态
     */
    fun setRegisterYesSelect(isSelectYes: Boolean) {
        val regUnit = getView<TextView>(R.id.tv_ars_registerUnit)
        val regUnitLine = getView<TextView>(R.id.tv_ars_LineUnit)
        val regParty = getView<TextView>(R.id.tv_ars_registerParty)
        val regPartyLine = getView<TextView>(R.id.tv_ars_LineParty)
        regUnit?.isSelected = isSelectYes
        regParty?.isSelected = !isSelectYes
        if (regUnit.isSelected) {
            regUnitLine?.visibility = View.VISIBLE
            regPartyLine?.visibility = View.GONE
        } else {
            regUnitLine?.visibility = View.GONE
            regPartyLine?.visibility = View.VISIBLE
        }

    }

    /**
     * 设置adatper
     */
    fun setAdapterData(adapter: ManagerViewPageAdapter) {
        getView<ViewPager>(R.id.vp_ars_registerPager)?.adapter = adapter
    }

    /**
     * 设置viewpager位置
     */
    fun setViewPagerPos(currentPos: Int) {
        getView<ViewPager>(R.id.vp_ars_registerPager)?.currentItem = currentPos

    }

    /**
     * 设置viewPager的监听
     */
    fun bindViewPagerLisener(listener: ViewPager.OnPageChangeListener) {
        getView<ViewPager>(R.id.vp_ars_registerPager)?.addOnPageChangeListener(listener)
    }


    /**
     *  设置顶部街道数据
     */
    fun setStreetName(name: String?) {
        val viewName = getView<TextView>(R.id.tv_ars_streetName)
        viewName?.text = "$name -报到统计"
    }

}